﻿/*
 * Imigrasi SMS (Special built for Immigration Office)
 * Copyright (C) 2010 Wish Enterprise Development Team

 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * 
 * Contact Us:
 * Author   : Khoirul Imamudin
 * E-Mail   : contact@wishenterprise.com     Website: http://www.wishenterprise.com
 * 
 * */

using System;
using System.Windows.Forms;
using SmsRepository;
using SmsRepository.Local;
using SmsRepository.Xlink;

namespace SmsAutorespond
{
    internal static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (!CekConnection())
            {
                using (var f = new DBLogonUI())
                {
                    f.ShowDialog();
                }
            }
            else
            {
                Application.Run(new MainWindow());
            }
        }

        /// <summary>
        /// Ceks the connection.
        /// </summary>
        /// <returns></returns>
        private static bool CekConnection()
        {
            try
            {
                var db1 = new InboxServiceBase();
                var db2 = new XLPassportFormBase();
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    string.Format(ex.Message), @"Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
        }
    }
}